#!/bin/bash

BRIDGE0=${BRIDGE0:-stpbridge0}
BRIDGE1=${BRIDGE1:-stpbridge1}
PORTA=${PORTA:-eno2}
PORTB=${PORTA:-eno3}

ip link add name ${BRIDGE0} type bridge vlan_filtering 1 stp_state 1
ip link set ${BRIDGE0} up

ip link add name ${BRIDGE1} type bridge vlan_filtering 1 stp_state 1
ip link set ${BRIDGE1} up

ip link set ${PORTA} master ${BRIDGE0}
ip link set ${PORTA} up

ip link set ${PORTB} master ${BRIDGE1}
ip link set ${PORTB} up

ip link add ${BRIDGE0}-veth1 type veth peer name ${BRIDGE1}-veth1
ip link set ${BRIDGE0}-veth1 master ${BRIDGE0}
ip link set ${BRIDGE0}br1-veth1 master ${BRIDGE1}

ip link set ${BRIDGE0}-veth1 up
ip link set ${BRIDGE1}-veth1 up

